package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import java.util.Optional;

import static com.iwhalecloud.bss.kite.cucc.service.attr.handler.FixedBandwidthHandler.checkVcValue;

/**
 * @author 王海龙
 * @version 2021/11/24 14:51
 * Description: VC绑定方式
 */
public class VcBindTypeHandler extends AbstractAttrHandler<KiteInst, AttrData> {
    /**
     * VC捆绑方式
     */
    public static final String VC_TYPE = "210004194";

    /**
     * VC捆绑数量
     */
    public static final String VC_NUM = "210004195";

    /**
     * 固定带宽
     */
    private static final String FIXED_BAND_WIDTH = "210004224";

    @Override
    public void before(KiteAttr attr, KiteInst inst, String value, AttrData data) {
        checkVcValue(value, Optional.ofNullable(inst.getAttr(VC_NUM)).orElseGet(KiteAttr::new).getValue(),Optional.ofNullable(inst.getAttr(FIXED_BAND_WIDTH)).orElseGet(KiteAttr::new).getValueDesc());
    }
}
